package test.beanTest;

import bean.admin.login.AdminLoginBean;

import static org.junit.Assert.assertEquals;

public class AdminLoginBeanTest {

    @org.junit.Test
    public void getCode() {
    }


    @org.junit.Test
    public void setCode() {
        AdminLoginBean ad = new AdminLoginBean();
        ad.setCode(1);
        assertEquals(1,ad.getCode());
    }

    @org.junit.Test
    public void getMessage() {
    }

    @org.junit.Test
    public void setMessage() {
        AdminLoginBean ad = new AdminLoginBean();
        ad.setMessage("xxx");
        assertEquals("xxx",ad.getMessage());
    }

    @org.junit.Test
    public void getToken() {
    }

    @org.junit.Test
    public void setToken() {
        AdminLoginBean ad = new AdminLoginBean();
        ad.setToken("yyy");
        assertEquals("yyy",ad.getToken());
    }

    @org.junit.Test
    public void admin_login_sucess() {
        AdminLoginBean ad = new AdminLoginBean();
        String recive = ad.admin_login("admin_1" ,"yhz");//正确的账户名和密码
        String [] parts = recive.split("#");
        String exp = "{\"code\":0,\"message\":\"登录成功\",\"token\":\"admin_1#1515416963146#yhz\"}";
        String [] parts1 = recive.split("#");
        assertEquals(parts[0],parts1[0]);
        assertEquals(parts[1],parts1[1]);
    }

    @org.junit.Test
    public void admin_login_fall_wps() {
        AdminLoginBean ad = new AdminLoginBean();
        String recive = ad.admin_login("admin_1" ,"yhz_wrong");//正确的账户名和密码
        String exp = "{\"code\":0,\"message\":\"密码错误\"}";
        assertEquals(recive,exp);
    }


    @org.junit.Test
    public void admin_login_fall_wac() {
        AdminLoginBean ad = new AdminLoginBean();
        String recive = ad.admin_login("admin_1_wrong" ,"yhz");//正确的账户名和密码
        String exp = "{\"code\":100,\"message\":\"java.sql.SQLException: Illegal operation on empty result set.\"}";
        assertEquals(exp,recive);
    }
}